package com.finance.system.dao;

import com.finance.system.bean.pojo.Organization;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by CBWL on 2017/3/17.
 */
@Component
public interface OrganizationMapper {
    List<Organization> listAll();

    /**
     * 根据名字或者code 模糊查询组织机构
     */
    List<Organization> listByNameOrCode(String key);

    Organization getById(Long id);

    /**
     * 根据code获取存在的数量
     */
    int countByCode(String code);

    /**
     * 根据id获取下级的数量
     */
    int countLowerLevelById(Long id);

    /**
     * 根据id 获取除了本身外存在的code数量
     */
    int countCodeOutofSelfById(@Param("code") String code, @Param("id") Long id);

    int add(Organization organization);

    int update(Organization organization);

    int del(@Param("uId") String uId, @Param("id") Long id);

    Organization getOrgByCode(@Param("code") String code);

    Organization getByCode(String code);

    String getCodeByName(String name);

    String getNameByCode(String code);
}
